/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-01-12 09:35:49
 * @LastEditTime : 2023-03-23 13:36:25
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Modal\ThrModalList\SampleParameter.jsx
 * @Description  :
 */
import axios from 'axios'
import { API_LIST } from '../../Api/Api'
import { commonTableList } from '../config'

export const SampleParameter = async ({ data }) => {
    let dataList = {
        url: 'SampleParameter',
        uuid: data.uuid,
        type: '添加样品报告',
        width: 1000,
        classification: 'FormModal',
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'code@asc' },
        additional: { sampleUuid: data.uuid },
        get: API_LIST()['getLabReportTemplates'],
        added: 'posSampleItemAddSampleItem',
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'standardModifyNo',
                title: '报告唯一性标识',
                valueType: 'input',
                width: 200,
            },
            {
                dataIndex: 'tableName',
                title: '样品名称',
                valueType: 'input',
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'spec',
                title: '规格型号',
                valueType: 'input',
                hideInSearch: true,
                width: 100,
            },
            {
                dataIndex: 'num',
                title: '数量',
                valueType: 'inputNumber',
                rules: true,
                hideInSearch: true,
                width: 100,
            },
            {
                dataIndex: 'unit',
                title: '单位',
                valueType: 'input',
                hideInSearch: true,
                rules: true,
                width: 100,
            },
            {
                dataIndex: 'sampleDisposal',
                title: '样品处置',
                valueType: 'input',
                hideInSearch: true,
                width: 100,
            },
            {
                dataIndex: 'factoryName',
                title: '厂家名称',
                valueType: 'input',
                hideInSearch: true,
                width: 300,
            },
            {
                dataIndex: 'factorySerialNo',
                title: '出厂编号',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'factoryDate',
                title: '出厂日期',
                valueType: 'Date',
                hideInSearch: true,
                showTime: true,
                width: 200,
            },
            {
                dataIndex: 'labReportTemplateUuid',
                title: '报告模板',
                valueType: 'select',
                valueEnum: [],
                rules: true,
            },
            {
                dataIndex: 'selectedTestTypeUuid',
                title: '报告参数',
                judge: 'labReportTemplateUuid',
                judgeType: '',
                valueType: 'selectMultiple',
                valueEnum: [],
                rules: true,
            },
        ],
    }

    const typeTree = await axios.get(API_LIST()['getLabReportTemplatesTestTypesTree'])
    let labReportTemplateUuidData = []
    typeTree.data.forEach(item => {
        labReportTemplateUuidData = [...labReportTemplateUuidData, { label: item.tableName, value: item.trueUuid }]
    })
    dataList.columns.find(v => v.dataIndex === 'labReportTemplateUuid').valueEnum = labReportTemplateUuidData
    dataList.columns.find(v => v.dataIndex === 'selectedTestTypeUuid').judgeType = typeTree.data

    return dataList
}
